package LeetcodeTest_forty_one;

//268. 丢失的数字
public class missingNumber
{
    public static void main(String[] args)
    {
        int[] nums={1,2};
        System.out.println(Solution.missingNumber(nums));
    }
}
class Solution
{
    public static int missingNumber(int[] nums)
    {
        int n=nums.length;
        int sum1=n*(n+1)/2;
        int sum2=0;
        for(int i=0;i<n;i++)
        {
            sum2+=nums[i];
        }
        if((sum1-sum2)!=0)
            return sum1-sum2;
        else
            return 0;
    }
}